﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Easydp.Models.Entities;
using Panny.Data;
namespace Easydp.Models
{
    public class TrainRouteManager
    {

        /// <summary>
        /// 搜索车站
        /// </summary>
        /// <param name="startStation">出发站</param>
        /// <param name="endStation">到达站</param>
        /// <returns></returns>
        public List<TT_TrainRoute> SearchByStationName(string startStation, string endStation)
        {
            List<TT_TrainRoute> list = new List<TT_TrainRoute>();
            using (SqlStoredProcedure selection = new SqlStoredProcedure("Pro_Panny_TrainStations_Search"))
            {
                selection.AddParameter("@StartStop", startStation);
                selection.AddParameter("@EndStop",endStation);
                while (selection.Read())
                {
                    TT_TrainRoute item = new TT_TrainRoute();
                    item.TrainNumber = selection["TrainNumber"].ToString();
                    item.TrainType = selection["TrainType"].ToString();
                    item.Position = selection["Position"].ToString();
                    item.FirstStation = selection["FirstStation"].ToString();                    
                    item.LastStation = selection["LastStation"].ToString();
                    item.StartStation = selection["StartStation"].ToString();
                    item.EndStation = selection["EndStation"].ToString();
                    item.StartTime = selection["StartTime"].ToString();
                    item.EndTime = selection["EndTime"].ToString();
                    item.RunTime = selection["RunTime"].ToString();
                    item.Countimes = selection["Countimes"].ToString();
                    item.M_rw = selection["M_rw"].ToString();
                    item.M_rz = selection["M_rz"].ToString();
                    item.M_yw = selection["M_yw"].ToString();
                    item.M_yz = selection["M_yz"].ToString();
                    list.Add(item);
                }
            }
            return list;
        }

        public List<TT_TrainRoute> SearchByTrainNumber(string trainNumber)
        {
            List<TT_TrainRoute> list = new List<TT_TrainRoute>();
            using (SqlStoredProcedure selection = new SqlStoredProcedure("Pro_Panny_TrainStations_SearchByTrainNumber"))
            {
                selection.AddParameter("@TrainNumber", trainNumber);
                while (selection.Read())
                {
                    TT_TrainRoute item = new TT_TrainRoute();
                    item.TrainNumber = selection["TrainNumber"].ToString();
                    item.Position = selection["Position"].ToString();
                    item.Station = selection["Station"].ToString();
                    item.StartTime = selection["StartTime"].ToString();
                    item.EndStation = selection["EndTime"].ToString();
                    item.StopTime = selection["StopTime"].ToString();
                    item.Mileage = selection["Mileage"].ToString();
                    item.RunTime = selection["RunTime"].ToString();
                    item.EndTime = selection["EndTime"].ToString();
                    item.M_rw = selection["M_rw"].ToString();
                    item.M_rz = selection["M_rz"].ToString();
                    item.M_yw = selection["M_yw"].ToString();
                    item.M_yz = selection["M_yz"].ToString();
                    list.Add(item);
                }
            }

            return list;
        }

    }
}
